package org.jeese.modules.demo.web;

import org.jeese.common.bean.ResponseResult;
import org.jeese.common.properties.TestProperties;
import org.jeese.common.properties.UploadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/")
public class PropertiesController {
	@Value(value = "${jeese.upload.defaultFolder}")
	private String defaultFolder;
	@Autowired
    private Environment env;
	@Autowired
	private UploadProperties uploadProperties;
	@Autowired
	private TestProperties testProperties;
	
	
	@RequestMapping("properties")
	@ResponseBody
	public ResponseResult properties() {
		ResponseResult result = new ResponseResult();
		result.put("1、使用@value方式", defaultFolder);
		result.put("2、使用Environment方式", env.getProperty("jeese.upload.defaultFolder"));
		result.put("3、使用@ConfigurationProperties方式", uploadProperties.getDefaultFolder());
		result.put("4、使用@ConfigurationProperties自定义方式", testProperties.getDefaultFolder());
		return result;
	}
}
